tic;
%------------------------------M, r, y
[nrowAeq, ncolAeq] = size(nAeq);

% check Aeq has full row rank
if rank(nAeq)==nrowAeq
    fullRowRank=true;
end

if fullRowRank   
    % generate a random integer between 1 and 50
    gamma = round(rand(1)*49)+1;
    
    cP = gamma * nC;
    
    % -----------------------Q, A', b'
    % generate a m x m non-singular matrix Q (deteminant =/= 0)
    Q = randi([0,5],nrowAeq);
    
    while det(Q)==0
        Q = randi([0,5],nrowAeq);
    end
    
    AeqP = Q * nAeq;                      % A' = QA
    beqP = Q * nbeq;                      % b' = Qb
    
    % generate a random n x m lambda
    Lambda =randi([0,5],ncolAeqP,nrowAeqP);
    
    AP = (nA - (Lambda * nAeq));               % B' = (B - LA)
    bP = -1 * (Lambda * nbeq);
    % display transform Time
    toc
    
%     options = mskoptimset('MaxIter',4000000, 'Simplex','on','Write', 'prob.opf','Diagnostics','on');
    options = mskoptimset('MaxIter',4000000, 'Write', 'prob.opf');
    
    tic;
    [y,fval,exitflag] =linprog(cP,AP,bP,AeqP,beqP,[],[],[],options);

%     [y,fval,exitflag] = linprog(cP,AP,bP,AeqP,beqP,[],[],[],options);
    toc
        
    % x2 = round (((M * y) - r) * 100 ) / 100;
%     x6 = (M * y) - r;
    
    n=1;
    nX6=[];
    temp=0;
    
    for ii=1:1:cRow
        if n <= length(cVariable)
            if ii == cVariable(n)
%                 if x(ii) < 0.0001
%                     temp = 0;
%                 else
%                 temp = (y(ii)*100)/100;
%                 end
                temp=y(ii);
                nX6{n,1} = ['x' num2str(ii) ' = ' num2str(temp)];
                n = n + 1;
            end
        end
    end
    nX6
end